<!DOCTYPE html>
<html  lang="en">
<head>
    <meta charset="utf-8" />

<meta name="generator" content="Hexo 4.2.0" />

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />

<title>「转」Mysql增删改查 - YEAR9&#39;s Blog | Archive of development experience</title>


    <meta name="description" content="前言：以下是MySQL最基本的增删改查语句，很多IT工作者都必须要会的命令，也是IT行业面试最常考的知识点，由于是入门级基础命令，所有所有操作都建立在单表上，未涉及多表操作。 前提：在进行“增删改查”的操作之前，先建立一个包含数据表student的数据库（具体操作可以见MySQL之最基本命令）：">
<meta property="og:type" content="article">
<meta property="og:title" content="「转」Mysql增删改查">
<meta property="og:url" content="https://blog.year9.cn/posts/40657.html">
<meta property="og:site_name" content="YEAR9&#39;s Blog | Archive of development experience">
<meta property="og:description" content="前言：以下是MySQL最基本的增删改查语句，很多IT工作者都必须要会的命令，也是IT行业面试最常考的知识点，由于是入门级基础命令，所有所有操作都建立在单表上，未涉及多表操作。 前提：在进行“增删改查”的操作之前，先建立一个包含数据表student的数据库（具体操作可以见MySQL之最基本命令）：">
<meta property="og:locale" content="en_US">
<meta property="og:image" content="https://blog.year9.cn/images/og_image.png">
<meta property="article:published_time" content="2020-03-09T09:20:55.000Z">
<meta property="article:modified_time" content="2020-03-24T12:20:57.050Z">
<meta property="article:author" content="YEAR9">
<meta property="article:tag" content="year9.cn">
<meta property="article:tag" content="ITblog">
<meta property="article:tag" content="九岁时光">
<meta property="article:tag" content="PTA">
<meta property="article:tag" content="CTF">
<meta property="article:tag" content="数据结构与算法">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://blog.year9.cn/images/og_image.png">





<link rel="alternative" href="/atom.xml" title="「转」Mysql增删改查" type="application/atom+xml">



<link rel="icon" href="/images/favicon.svg">


<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.7.2/css/bulma.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.1/css/all.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Ubuntu:400,600|Source+Code+Pro">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@9.12.0/styles/atom-one-light.css">


    
    
<style>body>.footer,body>.navbar,body>.section{opacity:0}</style>

    
    
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/lightgallery@1.6.8/dist/css/lightgallery.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/justifiedGallery@3.7.0/dist/css/justifiedGallery.min.css">

    
    
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/outdatedbrowser@1.1.5/outdatedbrowser/outdatedbrowser.min.css">

    
    
    
    
<link rel="stylesheet" href="/css/back-to-top.css">

    
    
    
    
    
    
    
    <link rel="stylesheet" href="/css/progressbar.css">
<script src="https://cdn.jsdelivr.net/npm/pace-js@1.0.2/pace.min.js"></script>
    
    
    


<link rel="stylesheet" href="/css/style.css">
    <meta name="baidu-site-verification" content="uZwQxsLLR3" />
<!--         <style> 
        html { 
            -webkit-filter: grayscale(100%); 
            -moz-filter: grayscale(100%); 
            -ms-filter: grayscale(100%); 
            -o-filter: grayscale(100%); 
            filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);  
            _filter:none; 
        } 
    </style>  -->
</head>
<body class="is-3-column">
    <nav class="navbar navbar-main">
    <div class="container">
        <div class="navbar-brand is-flex-center">
            <a class="navbar-item navbar-logo" href="/">
            
                <img src="/images/logo.png" alt="「转」Mysql增删改查" height="28">
            
            </a>
        </div>
        <div class="navbar-menu">
            
            <div class="navbar-start">
                
                <a class="navbar-item"
                href="/">Home</a>
                
                <a class="navbar-item"
                href="/archives">Archives</a>
                
                <a class="navbar-item"
                href="/categories">Categories</a>
                
                <a class="navbar-item"
                href="/tags">Tags</a>
                
                <a class="navbar-item"
                href="/posts/27225.html">About</a>
                
            </div>
            
            <div class="navbar-end">
                
                    
                    <a class="navbar-item" target="_blank" rel="noopener" title="Download on GitHub" href="https://gitee.com/year9">
                        
                        <i class="fab fa-github"></i>
                        
                    </a>
                    
                
                
                
                <a class="navbar-item search" title="Search" href="javascript:;">
                    <i class="fas fa-search"></i>
                </a>
                
            </div>
        </div>
    </div>
</nav>
    
    <section class="section">
        <div class="container">
            <div class="columns">
                <div class="column is-8-tablet is-8-desktop is-6-widescreen has-order-2 column-main">
<div class="card">
    
    <div class="card-content article ">
        
        <div class="level article-meta is-size-7 is-uppercase is-mobile is-overflow-x-auto">
            <div class="level-left">
                <time class="level-item has-text-grey" datetime="2020-03-09T09:20:55.000Z">2020-03-09</time>
                
                <div class="level-item">
                <a class="has-link-grey -link" href="/categories/%E9%9A%8F%E7%AC%94/">随笔</a>
                </div>
                
                
                <span class="level-item has-text-grey">
                    
                    
                    35 minutes read (About 5227 words)
                </span>
                
                
            </div>
        </div>
        
        <h1 class="title is-size-3 is-size-4-mobile has-text-weight-normal">
            
                「转」Mysql增删改查
            
        </h1>
        <div class="content">
            <p>前言：以下是MySQL最基本的增删改查语句，很多IT工作者都必须要会的命令，也是IT行业面试最常考的知识点，由于是入门级基础命令，所有所有操作都建立在单表上，未涉及多表操作。</p>
<p>前提：在进行“增删改查”的操作之前，先建立一个包含数据表student的数据库（具体操作可以见MySQL之最基本命令）：<br> <a id="more"></a><br>1、“增”——添加数据</p>
<p>1.1 为表中所有字段添加数据</p>
<p>1.1.1 INSERT 语句中指定所有字段名</p>
<p>语法：INSERT INTO 表名（字段名1，字段名2，…）</p>
<p>　　　　　　 VALUES（值1，值2，…）；</p>
<p>举例：INSERT INTO student(id,name,grade)</p>
<p>　　 VALUES(1,’zhangshan’,98);</p>
<p>使用SELECT * FROM student;命令查看结果为：</p>
<p>表示数据已经成功插入。</p>
<p>1.1.2 INSERT语句中不指定字段名</p>
<p>若不指定字段名，则添加的值的顺序应和字段在表中的顺序完全一致。</p>
<p>语法：INSERT INTO 表名 VALUES(值11，值2，…）；</p>
<p>举例：INSERT INTO student</p>
<p>　　 VALUES (2,’lisi’,62);</p>
<p>使用SELECT * FROM student;命令查看结果为：</p>
<p>1.2 为表的指定字段添加数据</p>
<p>为指定字段添加数据，即只向部分字段添加值，而其他字段的值为表定义时的默认值。</p>
<p>语法：INSERT INTO 表名（字段1，字段2，…）</p>
<p>　　 VALUES(值1，值2，…）</p>
<p>举例：INSERT INTO student(id,name)</p>
<p>　　 VALUES(3,’wangwu’);</p>
<p>使用SELECT * FROM student;命令查看结果为：</p>
<p>从结果中可以看出，新记录的grade字段值为NULL，是因为添加时为指明grade的值，系统会自动添加默认值。</p>
<p>1.3 INSERT语句的其他写法</p>
<p>语法：INSERT INTO 表名</p>
<p>　　 SET 字段名1=值1[,字段名2=值2，…]</p>
<p>举例：INSERT INTO student</p>
<p>　　 SET id=4，name=’zhaoliu’,grade=72;</p>
<p>使用SELECT * FROM student;命令查看结果为：</p>
<p>1.4 同时添加多条数据</p>
<p>语法：INSERT INTO 表名[(字段名1，字段名2，…)]</p>
<p>　　　VALUES （值1，值2，…），（值1，值2，…），</p>
<p>　　　…</p>
<p>　　　（值1，值2，…）</p>
<p>举例：INSERT INTO student VALUES</p>
<p>　　　　(5，‘lilei’,99),</p>
<p>　　　　(6,’hanmeimei’,87),</p>
<p>　　　　(8,’poly’,76);</p>
<p>使用SELECT * FROM student;命令查看结果为：</p>
<p>2、“删”——删除数据</p>
<p>语法：DELETE FROM 表名 [WHERE 条件表达式</p>
<p>2.1 删除部分数据</p>
<p>即删除指定的部分数据，需要使用WHERE子句来指定删除记录的条件。</p>
<p>举例：删除student表中的id值为7的记录</p>
<p>命令：DELETE FROM student</p>
<p>　　　WHERE id=7;</p>
<p>使用SELECT * FROM student;命令查看结果为：</p>
<p>可见id为7的记录已被成功删除。</p>
<p>2.2 删除全部数据</p>
<p>若 DELETE 语句中没有使用WHERE语句，则会将表中所有记录都删除。</p>
<p>语法：DELETE FROM 表名</p>
<p>举例：删除student表中的所有记录</p>
<p>命令：DELETE FROM student；</p>
<p>使用SELECT * FROM student;命令查看结果为：</p>
<p>可见student表中记录为空，说明表中所有数据已被成功删除。</p>
<p>2.2 删除全部数据的另一种方法——TRUNCATE</p>
<p>语法：TRUNCTE [TABLE ] 表名</p>
<p>举例：TRUNCATE TABLE student；即可删除student表</p>
<p>注意：</p>
<p>（1）DELETE 后面可以跟WHERE子句指定删除部分记录，TRUNCATE只能删除整个表的所有记录</p>
<p>（2）使用TRUNCATE语句删除记录后，新添加的记录时，自动增长字段（如本文中student表中的 id 字段）会默认从1开始，而使用DELETE删除记录后，新添加记录时，自动增长字段会从删除时该字段的的最大值加1开始计算（即原来的id最大为5，则会从6开始计算）。所以如果是想彻底删除一个表的记录而且不会影响到重新添加记录，最好使用TRUNCATE来删除整个表的记录。</p>
<p>3、“改”——更新数据</p>
<p>更新数据指对表中现存的数据进行修改。</p>
<p>语法：UPDATE 表名</p>
<p>　　　　　　SET 字段名1=值1，[ ，字段名2=值2，…]</p>
<p>　　　　　　[ WHERE 条件表达式 ]</p>
<p>在执行后面的语句之前，先使用INSERT语句往student表中插入以下数据：</p>
<p>3.1 UPDATE 更新部分数据</p>
<p>指更新指定表中的指定记录，使用WHERE 子句来指定。</p>
<p>举例：将student表中id值为1=记录，将其name字段的值改为‘caocao’，grade字段的值改为50。</p>
<p>先查询之前的记录：SELECT * FROM student WHERE id=1;</p>
<p>显示为：</p>
<p>命令：UPDATE student</p>
<p>　　　　SET name=‘caocao’,grade=50</p>
<p>　　　　WHERE id=1;</p>
<p>使用SELECT * FROM student;命令查看结果为：</p>
<p>可见表中数据已被成功更新。</p>
<p>注意：还可以使用其他WHERE条件表达式，如：id &gt; 4;</p>
<p>3.2 UPDATE 更新全部数据</p>
<p>在UPDATE 语句中若不使用WHERE 子句，则会将表中所有记录的指定字段都进行更新。</p>
<p>举例：更新student表中全部记录，将grade字段都更新为80</p>
<p>命令：UPDATE student</p>
<p>　　　　SET grade=80；</p>
<p>使用SELECT * FROM student;命令查看结果为：</p>
<p>可以看出所有数据已被成功更新。</p>
<p>4、“查”——之单表查询</p>
<p>MySQL从数据表中查询数据最基本的语句是SELECT语句，在前面的“增删查”已经使用过：SELECT * FROM 表名，也就是查询指定数据表中的所有数据。下面将对SELECT语句进行详细介绍。</p>
<p>在进行后面的操作之前我们先建立一个新的数据表student2，如下：<br>　　CREATE TABLE student2<br>　　(<br>　　　　id INT(3) PRIMARY KEY AUTO_INCREMENT,<br>　　　　name VARCHAR(20) NOT NULL,<br>　　　　grade FLOAT,gender CHAR(2)<br>　　);<br>此处的PRIMARY KEY表示将该字段设为主键，AUTO_INCREMENT表示将该字段设为开始值是 1,每条新记录自动递增 1,，所以在插入数据时不需为该字段设值；NOT NULL表示将该字段限制为非空值（此处不作详细讲解）<br>再向student2表中插入如下数据：<br>　　　　　　　　INSERT INTO student2(name,grade,gender)</p>
<p>　　　　　　　　VALUES (‘songjiang’,40,’男’),(‘wuyong’,100,’男’),(‘qinming’,90,’男’),(‘husanniang’,88,’女’),(‘sunerniang’,66,’女’),(‘wusong’,86,’男’),(‘linchong’,92,’男’),(‘yanqing’,90,NULL);<br>注意：若因为此处插入的数据包含了中文而导致无法插入，可将“男/女”改为“man/woman”，或者将字段编码改为utf-8（方法自行百度，此处不做讲解）。</p>
<p>4.1 简单查询</p>
<p>4.1.1 查询所有字段</p>
<p>语法：SELECT 字段名1，字段名2，…</p>
<p>　　　FROM 表名</p>
<p>举例：查询student2表中的所有记录</p>
<p>命令：SELECT id,name,grade ,gender</p>
<p>　　 FROM student2;</p>
<p>结果：</p>
<p>注意：字段顺序可以更改，如：</p>
<p>　　　　SELECT id,grade,gender ,name</p>
<p>　　 　　 FROM student2;</p>
<p>则显示的结果也会作出对应的调整：</p>
<p>4.1.2 在SELECT语句中使用（‘ * ’）通配符代替所有字段</p>
<p>语法：SELECT * FROM 表名；</p>
<p>在此前已多次使用此命令，所以此处不作赘述。</p>
<p>4.1.3 查询指定的部分字段</p>
<p>语法：SELECT 字段名1，字段名2，… FROM 表名；</p>
<p>举例：查询student2表中的name字段和gender字段</p>
<p>命令：SELECT name,gender FROM student2;</p>
<p>结果：</p>
<p>从结果中可以看到只显示了name和gender两个字段。</p>
<p>4.2 按条件查询</p>
<p>4.2.1 带关系运算符的查询</p>
<p>语法：SELECT 字段名1，字段名2，…</p>
<p>　　　FROM 表名</p>
<p>　　 WHERE 条件表达式</p>
<p>在WHERE子句中可以使用如下关系运算符：<br>关系运算符 说 明<br>　　　　= 　　　　等于<br>　　　　&lt;&gt; 　　　　不等于<br>　　　　!= 　　　　不等于<br>　　　　&lt; 　　　　小于<br>　　　　&lt;= 　　　　小于等于<br>　　　　&gt; 　　　　大于<br>　　　　&gt;= 　　　　大于等于</p>
<p>举例：查询student2表中id为4的人的id和name字段</p>
<p>命令：SELECT id，name FROM student2 WHERE id=4;</p>
<p>结果：</p>
<p>举例：查询student2表中grade大于80的人的name和grade字段</p>
<p>命令：SELECT name FROM student2 WHERE grade&gt;80;</p>
<p>结果：</p>
<p>4.2.2 带 IN 关键字的查询</p>
<p>IN关键字用于判断某个字段的值是否在指定集合中，若在，则该字段所在的记录将会被查询出来.</p>
<p>语法：SELECT * | 字段名1，字段名2，…</p>
<p>　　　FROM 表名</p>
<p>　　　WHERE 字段名 [ NOT ] IN （元素1，元素2，…）</p>
<p>举例：查询student2表中id值为1,2,3的记录</p>
<p>命令：SELECT * FROM student2 WHERE id IN （1,2,3）；</p>
<p>结果：</p>
<p>注意：NOT IN 与 IN 相反，查询的是不在指定范围内的记录。</p>
<p>4.2.3 带 BETWEEN AND 关键字的查询</p>
<p>BETWEEN AND 用于判断某个字段的值是否在指定范围之内，若在，则该字段所在的记录会被查询出来，反之不会。</p>
<p>语法：SELECT * | { 字段名1，字段名2，… }</p>
<p>　　　FROM 表名</p>
<p>　　 WHERE 字段名 [ NOT ] BETWEEN 值1 AND 值2；</p>
<p>举例：查询student2表中id值在2~5之间的人的id和name</p>
<p>命令：SELECT id,name FROM students WHERE id BETWEEN 2 AND 5;</p>
<p>结果：</p>
<p>注意：NOT BETWEEN AND 表示查询指定范围外的记录。</p>
<p>4.2.4 空值查询</p>
<p>在数据表中有些值可能为空值（NULL），空值不同于0，也不同于空字符串，需要使用 IS NULL 来判断字段的值是否为空值。</p>
<p>语法：SELECT * | 字段名1，字段名2，…</p>
<p>　　　FROM 表名</p>
<p>　　　WHERE 字段名 IS [ NOT ] NULL</p>
<p>举例：查询student2表中gender值为空值的记录。</p>
<p>命令：SELECT * FROM student2 WHERE gender IS NULL;</p>
<p>结果：</p>
<p>注意：IS NOT NULL 关键字用来查询字段不为空值的记录。</p>
<p>4.2.5 带 DISTINCT 关键字的查询</p>
<p>很多表中某些字段的数据存在重复的值，可以使用DISTINCT关键字来过滤重复的值，只保留一个值。</p>
<p>语法：SELECT DISTINCT 字段名 FROM 表名；</p>
<p>举例：查询student2表中gender字段的值，结果中不允许出行重复的值。</p>
<p>命令：SELECT DISTINCT gender FROM student2;</p>
<p>结果：</p>
<p>注意：DISTINCT 关键字还可作用于多个字段，则只有多个字段的值都完全相同时才会被认作是重复记录。</p>
<p>4.2.6 带 LIKE 关键字的查询</p>
<p>语法：SELECT * | 字段名1，字段名2，…</p>
<p>　　　FROM 表名</p>
<p>　　　WHERE 字段名 [ NOT ] LIKE ‘匹配字符串’;</p>
<p>（1）百分号（%）通配符</p>
<p>匹配任意长度的字符串，包括空字符串。例如，字符串“ c% ”匹配以字符 c 开始，任意长度的字符串，如“ ct ”，“ cut ”，“ current ”等；字符串“ c%g ”表示以字符 c 开始，以 g 结尾的字符串；字符串“ %y% ”表示包含字符“ y ”的字符串，无论“ y ”在字符串的什么位置。</p>
<p>举例1：查询student2表中name字段以字符“ s ”开头的人的id,name</p>
<p>命令：SELECT id,name FROM student2 WHERE name LIKE “S%”;</p>
<p>结果：</p>
<p>举例2：查询student2表中name字段以字符“ w ”开始，以字符“ g ”结尾的人的id，name。</p>
<p>命令：SELECT id,name FROM student2 WHERE name LIKE ‘w%g’;</p>
<p>结果：</p>
<p>举例3：查询student2表中name字段不包含“ y ”的人的id，name。</p>
<p>命令：SELECT id,name FROM student2 WHERE name NOT LIKE ‘%y%’;</p>
<p>结果：</p>
<p>（2）下划线（_）通配符</p>
<p>下划线通配符只匹配单个字符，若要匹配多个字符，需要使用多个下划线通配符。例如，字符串“ cu_ ”匹配以字符串“ cu ”开始，长度为3的字符，如“ cut ”，“ cup ”；字符串“ c__l”匹配在“ c ”和“ l ”之间包含两个字符的字符串，如“ cool ”。需要注意的是，连续的“<em>”之间不能有空格，例如“M</em> _QL”只能匹配“My SQL”，不能匹配“MySQL”。</p>
<p>举例：查询在student2表中name字段值以“ wu ”开始，以“ ong ”结束，并且中间只有一个字符的记录。</p>
<p>命令：SELECT * FROM student2 WHERE name LIKE ‘wu_ong’;</p>
<p>结果：</p>
<p>注意：若要查询的字段值本来就含有“ % ”或者“ _ ”,则要用“ \ ”进行转义，如要查询本身含有“ % ”的字符串，命令应改为 “ %%%”。</p>
<p>4.2.7 带 AND 关键字的多条件查询</p>
<p>在使用SELECT语句查询数据时，优势为了使查询结果更加精确，可以使用多个查询条件，如使用 AND 关键字可以连接两个或多个查询条件。</p>
<p>语法：SELECT * | 字段名1，字段名2，…</p>
<p>　　　FROM 表名</p>
<p>　　　WHERE 条件表达式1 AND 条件表达式2 [ … AND 条件表达式 n ];</p>
<p>举例：查询student2表中 id 字段小于5，并且 gender 字段值为“ 女 ”的人的id和name</p>
<p>命令：SELECT id,name FROM student2 WHERE id&lt;5 AND gender=’女’;</p>
<p>结果：</p>
<p>4.2.8 带 OR 关键字的多条件查询</p>
<p>与 AND 关键字不同，OR 关键字只要满足任意一个条件就会被查询出来</p>
<p>语法：SELECT * | 字段名1，字段名2，…</p>
<p>　　　FROM 表名</p>
<p>　　　WHERE 条件表达式1 OR 条件表达式2 [ … OR 条件表达式 n ];</p>
<p>举例：查询student2表中 id 字段小于3，或者 gender 字段值为“ 女 ”的人的id，name和gender</p>
<p>命令：SELECT id,name ,gender FROM student2 WHERE id&lt;3 OR gender=’女’;</p>
<p>结果：</p>
<p>4.2.9 OR 和 AND 一起使用的情况</p>
<p>OR 和 AND 一起使用的时候，AND 的优先级高于 OR，因此二者一起使用时，会先运算 AND 两边的表达式，再运算 OR 两边的表达式。</p>
<p>举例：查询student2表中gender值为“女”或者gender值为“男”并且grade字段值为100的人的记录</p>
<p>命令：SELECT * FROM student2 WHERE gender=’女’ OR gender=’男’ AND grade=100;</p>
<p>结果：</p>
<p>4.3 高级查询</p>
<p>4.3.1 聚合函数<br>函数名称 作用<br>　　　　COUNT() 　　　　返回某列的行数<br>　　　　SUM() 　　　　返回某列值的和<br>　　　　AVG() 　　　　返回某列的平均值<br>　　　　MAX() 　　　　返回某列的最大值<br>　　　　MIN() 　　　　返回某列的最小值</p>
<p>（1）COUNT()函数：统计记录的条数</p>
<p>语法：SELECT COUNT(*) FROM 表名</p>
<p>举例：查询student2表中一共有多少条记录</p>
<p>命令：SELECT COUNT(*) FROM student2;</p>
<p>结果：</p>
<p>（2）SUM()函数：求出表中某个字段所有值的总和</p>
<p>语法：SELECT SUM(字段名) FROM 表名；</p>
<p>举例：求出student2表中grade字段的总和</p>
<p>命令：SELECT SUM(grade) FROM student2;</p>
<p>结果：</p>
<p>（3）AVG()函数：求出表中某个字段所有值的平均值</p>
<p>语法：SELECT AVG(字段名) FROM 表名；</p>
<p>举例：求出student2表中grade字段的平均值</p>
<p>命令：SELECT AVG(grade) FROM student2;</p>
<p>结果：</p>
<p>（4）MAX()函数：求出表中某个字段所有值的最大值</p>
<p>语法：SELECT MAX(字段名) FROM 表名；</p>
<p>举例：求出student2表中所有人grade字段的最大值</p>
<p>命令：SELECT MAX(grade) FROM student2;</p>
<p>结果：</p>
<p>（5）MIN()函数：求出表中某个字段所有值的最小值</p>
<p>语法：SELECT MIN(字段名) FROM 表名；</p>
<p>举例：求出student2表中所有人grade字段的最小值</p>
<p>命令：SELECT MIN(grade) FROM student2;</p>
<p>结果：</p>
<p>4.3.2 对查询结果进行排序</p>
<p>语法：SELECT 字段名1，字段名2，…</p>
<p>　　　FROM 表名</p>
<p>　　　ORDER BY 字段名1 [ ASC | DESC ],字段名2 [ ASC | DESC ]…</p>
<p>在该语法中指定的字段名是对查询结果进行排序的依据，ASC表示升序排列，DESC 表示降序排列，默认情况是升序排列。</p>
<p>举例1：查出student2表中的所有记录，并按照grade字段进行升序排序</p>
<p>命令：SELECT * FROM student2</p>
<p>　　　ORDER BY grade;</p>
<p>结果：</p>
<p>举例2：查出student2表中的所有记录，并按照grade字段进行降序排序</p>
<p>命令：SELECT * FROM student2</p>
<p>　　　ORDER BY grade DESC;</p>
<p>结果：</p>
<p>4.3.3 分组查询</p>
<p>在对表中数据进行统计的时候，可以使用GROUP BY 按某个字段或者多个字段进行分组，字段中值相同的为一组，如男生分为一组，女生分为一组。</p>
<p>语法：SELECT 字段名1，字段名2，…</p>
<p>　　　FROM 表名</p>
<p>　　　GROUP BY 字段名1，字段名2，… [ HAVING 条件表达式 ];</p>
<p>（1）单独使用 GROUP BY 进行分组</p>
<p>单独使用GROUP BY 关键字，查询的是每个分组中的一条记录</p>
<p>举例：查询student2表中的数据，按照gender字段进行分组。</p>
<p>命令：SELECT * FROM student2 GROUP BY gender;</p>
<p>结果：</p>
<p>注意：若在此2例中键入命令之后出现“#1055”错误，无法完成分组查询，是由于MySQL版本升级到了5.7，可自行百度“MySQL 1055错误”参考解决办法。</p>
<p>（2） GROUP BY 和聚合函数一起使用</p>
<p>GROUP BY 和聚合函数一起使用，可以统计出某个或者某些字段在一个分组中的最大值、最小值、平均值等。</p>
<p>举例：将student2表按照gender字段进行分组查询，计算出每组共有多少个人。</p>
<p>命令：SELECT COUNT(*) ,gender FROM student2 GROUP BY gender;</p>
<p>结果：</p>
<p>（2） GROUP BY 和 HAVING 关键字一起使用</p>
<p>HAVING关键字和WHERE关键字的作用相同，区别在于HAVING 关键字可以跟聚合函数，而WHERE 关键字不能。通常HAVING 关键字都和GROUP BY一起使用，用于对分组后的结果进行过滤。</p>
<p>举例：将student2表按照gender字段进行分组查询，查询出grade字段值之和小于300的分组</p>
<p>命令：SELECT sum(grade),gender FROM student2 GROUP BY gender HAVING SUM(grade) &lt; 300;</p>
<p>结果：</p>
<p>4.3.4 使用 LIMIT 限制查询结果的数量</p>
<p>语法：SELECT 字段名2，字段名2，…</p>
<p>　　　FROM 表名</p>
<p>　　　LIMIT [ OFFSET ,] 记录数</p>
<p>在此语法中，LIMIT 后面可以跟两个参数，第一个参数“ OFFSET ”表示偏移量，如果偏移量为0，则从查询结果的第一条记录开始，偏移量为1则从查询结果中的第二条记录开始，以此类推。OFFSET为可选值，默认值为0，第二个参数“记录数”表示指定返回查询记录的条数。</p>
<p>举例1：查询student2表中的前四条记录。</p>
<p>命令：SELECT * FROM student LIMIT 4;</p>
<p>结果：</p>
<p>举例2：查询student2表中grade字段从第五位到第八位的人（从高到低）</p>
<p>命令：SELECT * FROM student2 ORDER BY grade DESC LIMIT 4,4;</p>
<p>结果：</p>
<p>4.3.5 函数（列表）</p>
<p>见MySQL之常用函数</p>
<p>4.4 为表和字段取别名</p>
<p>4.4.1 为表取别名</p>
<p>在进行查询操作时，如果表名很长使用起来不方便，可以为表取一个别名来代替表的名称。</p>
<p>语法：SELECT * FROM 表名 [ AS ] 别名；</p>
<p>举例：为student2表起一个别名s，并查询student2表中gender字段值为“女”的记录</p>
<p>命令：SELECT * FROM student2 AS s WHERE s.gender=’女’;</p>
<p>结果：</p>
<p>4.4.1 为字段取别名</p>
<p>语法：SELECT 字段名 [ AS ] 别名 [ ,字段名 [AS] 别名，…] FROM 表名 ；</p>
<p>举例：查询student2表中的所有记录的name和gender字段值，并未这两个字段起别名stu_name和stu_gender</p>
<p>命令：SELECT name AS stu_name,gender AS stu_gender FROM student2;</p>
<p>结果：</p>
<p>哪怕是咸鱼，也要做最咸的那条</p>
<p>转：白居不易1101<br>(<a href="https://www.cnblogs.com/heyangblog/p/7624645.html">https://www.cnblogs.com/heyangblog/p/7624645.html</a>)</p>

        </div>
        
        
        
        <div class="social-share"></div>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js@1.0.16/dist/css/share.min.css">
<script src="https://cdn.jsdelivr.net/npm/social-share.js@1.0.16/dist/js/social-share.min.js"></script>
        
    </div>
</div>



<div class="card">
    <div class="card-content">
        <h3 class="menu-label has-text-centered">Like this article? Support the author with</h3>
        <div class="buttons is-centered">
            
                
<a class="button is-info donate">
    <span class="icon is-small">
        <i class="fab fa-alipay"></i>
    </span>
    <span>Alipay</span>
    <div class="qrcode"><img src="https://www.year9.cn/afdian-year9.png" alt="Alipay"></div>
</a>

                
                
<a class="button is-success donate">
    <span class="icon is-small">
        <i class="fab fa-weixin"></i>
    </span>
    <span>Wechat</span>
    <div class="qrcode"><img src="https://www.year9.cn/afdian-year9.png" alt="Wechat"></div>
</a>

                
                <!-- Visit https://www.paypal.com/donate/buttons/ to get your donate button -->

<a class="button is-warning donate" onclick="document.getElementById(&#39;paypal-donate-form&#39;).submit()">
    <span class="icon is-small">
        <i class="fab fa-paypal"></i>
    </span>
    <span>Paypal</span>
</a>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank" rel="noopener" id="paypal-donate-form">
    <input type="hidden" name="cmd" value="_donations" />
    <input type="hidden" name="business" value="https://www.year9.cn/afdian-year9.png" />
    <input type="hidden" name="currency_code" value="USD" />
</form>

                
                
<a class="button is-danger donate" href="https://www.year9.cn" target="_blank" rel="noopener">
    <span class="icon is-small">
        <i class="fab fa-patreon"></i>
    </span>
    <span>Patreon</span>
</a>

                
        </div>
    </div>
</div>



<div class="card card-transparent">
    <div class="level post-navigation is-flex-wrap is-mobile">
        
        <div class="level-start">
            <a class="level level-item has-link-grey  article-nav-prev" href="/posts/11638.html">
                <i class="level-item fas fa-chevron-left"></i>
                <span class="level-item">「随笔」谈谈最近在干嘛</span>
            </a>
        </div>
        
        
        <div class="level-end">
            <a class="level level-item has-link-grey  article-nav-next" href="/posts/58803.html">
                <span class="level-item">「转」Mysql的连接关闭</span>
                <i class="level-item fas fa-chevron-right"></i>
            </a>
        </div>
        
    </div>
</div>



<div class="card">
    <div class="card-content">
        <h3 class="title is-5 has-text-weight-normal">Comments</h3>
        
<div id="lv-container" data-id="city" data-uid="MTAyMC80OTIxMC8yNTcwNA==">
    <script type="text/javascript">
        (function(d, s) {
            var j, e = d.getElementsByTagName(s)[0];

            if (typeof LivereTower === 'function') { return; }

            j = d.createElement(s);
            j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
            j.async = true;

            e.parentNode.insertBefore(j, e);
        })(document, 'script');
    </script>
    <noscript> Please activate JavaScript for write a comment in LiveRe</noscript>
</div>

    </div>
</div>
</div>
                




<div class="column is-4-tablet is-4-desktop is-3-widescreen  has-order-1 column-left ">
    
        
<div class="card widget">
    <div class="card-content">
        <nav class="level">
            <div class="level-item has-text-centered" style="flex-shrink: 1">
                <div>
                    
                    <figure class="image is-128x128 has-mb-6">
                        <img class="" src="https://q1.qlogo.cn/g?b=qq&amp;nk=12197673&amp;s=640" alt="YEAR9">
                    </figure>
                    
                    <p class="is-size-4 is-block">
                        YEAR9
                    </p>
                    
                    
                    <p class="is-size-6 is-block">
                        a simple coder for Java &amp; PHP
                    </p>
                    
                    
                    <p class="is-size-6 is-flex is-flex-center has-text-grey">
                        <i class="fas fa-map-marker-alt has-mr-7"></i>
                        <span>Xiamen Fujian</span>
                    </p>
                    
                </div>
            </div>
        </nav>
        <nav class="level is-mobile">
            <div class="level-item has-text-centered is-marginless">
                <div>
                    <p class="heading">
                        Posts
                    </p>
                    <a href="/archives">
                        <p class="title has-text-weight-normal">
                            36
                        </p>
                    </a>
                </div>
            </div>
            <div class="level-item has-text-centered is-marginless">
                <div>
                    <p class="heading">
                        Categories
                    </p>
                    <a href="/categories">
                        <p class="title has-text-weight-normal">
                            10
                        </p>
                    </a>
                </div>
            </div>
            <div class="level-item has-text-centered is-marginless">
                <div>
                    <p class="heading">
                        Tags
                    </p>
                    <a href="/tags">
                        <p class="title has-text-weight-normal">
                            27
                        </p>
                    </a>
                </div>
            </div>
        </nav>
        
        <div class="level">
            <a class="level-item button is-link is-rounded" href="https://gitee.com/year9" target="_blank" rel="noopener">
                Follow</a>
        </div>
        
        
        
        <div class="level is-mobile">
            
            <a class="level-item button is-white is-marginless" target="_blank" rel="noopener"
                title="Gitee" href="https://gitee.com/year9">
                
                <i class="fab fa-github-alt"></i>
                
            </a>
            
            <a class="level-item button is-white is-marginless" target="_blank" rel="noopener"
                title="Year9&#39;s Homepage" href="https://www.year9.cn">
                
                <i class="fab fa-internet-explorer"></i>
                
            </a>
            
            <a class="level-item button is-white is-marginless" target="_blank" rel="noopener"
                title="Twitter" href="https://gitee.com/year9">
                
                <i class="fab fa-twitter"></i>
                
            </a>
            
            <a class="level-item button is-white is-marginless" target="_blank" rel="noopener"
                title="Dribbble" href="https://gitee.com/year9">
                
                <i class="fab fa-dribbble"></i>
                
            </a>
            
            <a class="level-item button is-white is-marginless" target="_blank" rel="noopener"
                title="RSS" href="/atom.xml">
                
                <i class="fas fa-rss"></i>
                
            </a>
            
        </div>
        
    </div>
</div>
    
        
    
        <div class="card widget">
    <div class="card-content">
        <div class="menu">
        <h3 class="menu-label">
            Links
        </h3>
        <ul class="menu-list">
        
            <li>
                <a class="level is-mobile" href="https://www.year9.cn" target="_blank" rel="noopener">
                    <span class="level-left">
                        <span class="level-item">Year9&#39;s Homepage</span>
                    </span>
                    <span class="level-right">
                        <span class="level-item tag">www.year9.cn</span>
                    </span>
                </a>
            </li>
        
            <li>
                <a class="level is-mobile" href="http://www.joyhuang.top" target="_blank" rel="noopener">
                    <span class="level-left">
                        <span class="level-item">joyhuang Blog</span>
                    </span>
                    <span class="level-right">
                        <span class="level-item tag">www.joyhuang.top</span>
                    </span>
                </a>
            </li>
        
            <li>
                <a class="level is-mobile" href="https://blog.dextercai.com" target="_blank" rel="noopener">
                    <span class="level-left">
                        <span class="level-item">DexterCai Blog</span>
                    </span>
                    <span class="level-right">
                        <span class="level-item tag">blog.dextercai.com</span>
                    </span>
                </a>
            </li>
        
            <li>
                <a class="level is-mobile" href="https://vincent-vic.gitee.io" target="_blank" rel="noopener">
                    <span class="level-left">
                        <span class="level-item">Vincent Vic Blog</span>
                    </span>
                    <span class="level-right">
                        <span class="level-item tag">vincent-vic.gitee.io</span>
                    </span>
                </a>
            </li>
        
        </ul>
        </div>
    </div>
</div>

    
        
<div class="card widget">
    <div class="card-content">
        <div class="menu">
            <h3 class="menu-label">
                Categories
            </h3>
            <ul class="menu-list">
            <li>
        <a class="level is-marginless" href="/categories/Minecraft/">
            <span class="level-start">
                <span class="level-item">Minecraft</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">1</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/%E5%B7%A5%E4%BD%9C%E7%AC%94%E8%AE%B0/">
            <span class="level-start">
                <span class="level-item">工作笔记</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">2</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/%E6%88%91%E7%9A%84%E5%BC%80%E5%8F%91%E4%B9%8B%E8%B7%AF/">
            <span class="level-start">
                <span class="level-item">我的开发之路</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">2</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/%E6%8A%80%E6%9C%AF%E5%88%86%E4%BA%AB/">
            <span class="level-start">
                <span class="level-item">技术分享</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">3</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E4%B8%8E%E7%AE%97%E6%B3%95/">
            <span class="level-start">
                <span class="level-item">数据结构与算法</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">9</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/%E6%99%9A%E5%AE%89%E7%B3%BB%E5%88%97/">
            <span class="level-start">
                <span class="level-item">晚安系列</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">6</span>
            </span>
        </a><ul><li>
        <a class="level is-marginless" href="/categories/%E6%99%9A%E5%AE%89%E7%B3%BB%E5%88%97/%E6%8A%80%E6%9C%AF%E5%88%86%E4%BA%AB/">
            <span class="level-start">
                <span class="level-item">技术分享</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">1</span>
            </span>
        </a></li></ul></li><li>
        <a class="level is-marginless" href="/categories/%E8%BD%AF%E4%BB%B6%E5%8F%91%E5%B8%83/">
            <span class="level-start">
                <span class="level-item">软件发布</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">1</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/%E9%80%9A%E7%9F%A5/">
            <span class="level-start">
                <span class="level-item">通知</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">2</span>
            </span>
        </a></li><li>
        <a class="level is-marginless" href="/categories/%E9%9A%8F%E7%AC%94/">
            <span class="level-start">
                <span class="level-item">随笔</span>
            </span>
            <span class="level-end">
                <span class="level-item tag">9</span>
            </span>
        </a></li>
            </ul>
        </div>
    </div>
</div>
    
        <div class="card widget">
    <div class="card-content">
        <h3 class="menu-label">
            Tag Cloud
        </h3>
        <a href="/tags/Flash/" style="font-size: 10px;">Flash</a> <a href="/tags/Linux/" style="font-size: 10px;">Linux</a> <a href="/tags/Vue-js/" style="font-size: 10px;">Vue.js</a> <a href="/tags/%E4%B8%AD%E5%9B%BD%E5%A4%A7%E5%AD%A6Mooc/" style="font-size: 10px;">中国大学Mooc</a> <a href="/tags/%E5%8A%A0%E6%B2%B9/" style="font-size: 15px;">加油</a> <a href="/tags/%E5%93%88%E5%A4%AB%E6%9B%BC%E6%A0%91/" style="font-size: 10px;">哈夫曼树</a> <a href="/tags/%E5%A0%86%E6%A0%88/" style="font-size: 10px;">堆栈</a> <a href="/tags/%E5%AD%A6%E4%B9%A0Vue-js/" style="font-size: 10px;">学习Vue.js</a> <a href="/tags/%E5%BC%80%E5%8F%91%E8%BF%9B%E5%BA%A6/" style="font-size: 10px;">开发进度</a> <a href="/tags/%E6%88%91%E5%A4%AA%E9%9A%BE%E4%BA%86/" style="font-size: 10px;">我太难了</a> <a href="/tags/%E6%8B%AF%E6%95%91007/" style="font-size: 10px;">拯救007</a> <a href="/tags/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/" style="font-size: 20px;">数据结构</a> <a href="/tags/%E6%96%B0%E5%86%A0%E7%97%85%E6%AF%92/" style="font-size: 10px;">新冠病毒</a> <a href="/tags/%E6%97%85%E6%B8%B8%E8%A7%84%E5%88%92/" style="font-size: 10px;">旅游规划</a> <a href="/tags/%E6%97%A5%E5%BF%97/" style="font-size: 10px;">日志</a> <a href="/tags/%E6%99%9A%E5%AE%89/" style="font-size: 20px;">晚安</a> <a href="/tags/%E6%99%9A%E5%AE%89%E7%B3%BB%E5%88%97/" style="font-size: 10px;">晚安系列</a> <a href="/tags/%E6%A0%88/" style="font-size: 10px;">栈</a> <a href="/tags/%E6%A0%91/" style="font-size: 10px;">树</a> <a href="/tags/%E6%B5%8F%E8%A7%88%E5%99%A8/" style="font-size: 10px;">浏览器</a> <a href="/tags/%E7%AC%A6%E5%8F%B7%E9%85%8D%E5%AF%B9/" style="font-size: 10px;">符号配对</a> <a href="/tags/%E8%B8%A9%E5%9D%91/" style="font-size: 10px;">踩坑</a> <a href="/tags/%E8%BE%9B%E9%85%B8%E5%8E%86%E7%A8%8B/" style="font-size: 10px;">辛酸历程</a> <a href="/tags/%E9%93%BE%E6%A0%88/" style="font-size: 10px;">链栈</a> <a href="/tags/%E9%98%9F%E5%88%97/" style="font-size: 10px;">队列</a> <a href="/tags/%E9%98%9F%E6%A0%88/" style="font-size: 10px;">队栈</a> <a href="/tags/%E9%BB%98%E5%93%80/" style="font-size: 10px;">默哀</a>
    </div>
</div>
    
    
        <div class="column-right-shadow is-hidden-widescreen ">
        
            <div class="card widget">
    <div class="card-content">
        <h3 class="menu-label">
            Recent
        </h3>
        
        <article class="media">
            
            <div class="media-content">
                <div class="content">
                    <div><time class="has-text-grey is-size-7 is-uppercase" datetime="2020-05-12T15:09:00.000Z">2020-05-12</time></div>
                    <a href="/posts/10153.html" class="title has-link-black-ter is-size-6 has-text-weight-normal">晚安系列:聊聊最近的事情吧</a>
                    <p class="is-size-7 is-uppercase">
                        <a class="has-link-grey -link" href="/categories/%E6%99%9A%E5%AE%89%E7%B3%BB%E5%88%97/">晚安系列</a>
                    </p>
                </div>
            </div>
        </article>
        
        <article class="media">
            
            <div class="media-content">
                <div class="content">
                    <div><time class="has-text-grey is-size-7 is-uppercase" datetime="2020-04-26T09:58:00.000Z">2020-04-26</time></div>
                    <a href="/posts/31880.html" class="title has-link-black-ter is-size-6 has-text-weight-normal">关于队列、堆栈、树的数据结构总结</a>
                    <p class="is-size-7 is-uppercase">
                        <a class="has-link-grey -link" href="/categories/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E4%B8%8E%E7%AE%97%E6%B3%95/">数据结构与算法</a>
                    </p>
                </div>
            </div>
        </article>
        
        <article class="media">
            
            <div class="media-content">
                <div class="content">
                    <div><time class="has-text-grey is-size-7 is-uppercase" datetime="2020-04-05T01:47:00.000Z">2020-04-05</time></div>
                    <a href="/posts/19129.html" class="title has-link-black-ter is-size-6 has-text-weight-normal">开发进度：year9.cn完成了后端部分功能</a>
                    <p class="is-size-7 is-uppercase">
                        <a class="has-link-grey -link" href="/categories/%E6%88%91%E7%9A%84%E5%BC%80%E5%8F%91%E4%B9%8B%E8%B7%AF/">我的开发之路</a>
                    </p>
                </div>
            </div>
        </article>
        
        <article class="media">
            
            <div class="media-content">
                <div class="content">
                    <div><time class="has-text-grey is-size-7 is-uppercase" datetime="2020-04-03T12:11:00.000Z">2020-04-03</time></div>
                    <a href="/posts/17009.html" class="title has-link-black-ter is-size-6 has-text-weight-normal">全国哀悼日4月4日,为抗击疫情的战士们降半旗!</a>
                    <p class="is-size-7 is-uppercase">
                        <a class="has-link-grey -link" href="/categories/%E9%80%9A%E7%9F%A5/">通知</a>
                    </p>
                </div>
            </div>
        </article>
        
        <article class="media">
            
            <div class="media-content">
                <div class="content">
                    <div><time class="has-text-grey is-size-7 is-uppercase" datetime="2020-04-01T09:34:00.000Z">2020-04-01</time></div>
                    <a href="/posts/5527.html" class="title has-link-black-ter is-size-6 has-text-weight-normal">06-图2 Saving James Bond - Easy Version (25分)</a>
                    <p class="is-size-7 is-uppercase">
                        <a class="has-link-grey -link" href="/categories/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E4%B8%8E%E7%AE%97%E6%B3%95/">数据结构与算法</a>
                    </p>
                </div>
            </div>
        </article>
        
    </div>
</div>
        
            <div class="card widget">
    <div class="card-content">
        <div class="menu">
        <h3 class="menu-label">
            Archives
        </h3>
        <ul class="menu-list">
        
        <li>
            <a class="level is-marginless" href="/archives/2020/05/">
                <span class="level-start">
                    <span class="level-item">May 2020</span>
                </span>
                <span class="level-end">
                    <span class="level-item tag">1</span>
                </span>
            </a>
        </li>
        
        <li>
            <a class="level is-marginless" href="/archives/2020/04/">
                <span class="level-start">
                    <span class="level-item">April 2020</span>
                </span>
                <span class="level-end">
                    <span class="level-item tag">8</span>
                </span>
            </a>
        </li>
        
        <li>
            <a class="level is-marginless" href="/archives/2020/03/">
                <span class="level-start">
                    <span class="level-item">March 2020</span>
                </span>
                <span class="level-end">
                    <span class="level-item tag">22</span>
                </span>
            </a>
        </li>
        
        <li>
            <a class="level is-marginless" href="/archives/2020/02/">
                <span class="level-start">
                    <span class="level-item">February 2020</span>
                </span>
                <span class="level-end">
                    <span class="level-item tag">5</span>
                </span>
            </a>
        </li>
        
        </ul>
        </div>
    </div>
</div>
        
            <div class="card widget">
    <div class="card-content">
        <div class="menu">
            <h3 class="menu-label">
                Tags
            </h3>
            <div class="field is-grouped is-grouped-multiline">
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/Flash/">
                        <span class="tag">Flash</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/Linux/">
                        <span class="tag">Linux</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/Vue-js/">
                        <span class="tag">Vue.js</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E4%B8%AD%E5%9B%BD%E5%A4%A7%E5%AD%A6Mooc/">
                        <span class="tag">中国大学Mooc</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E5%8A%A0%E6%B2%B9/">
                        <span class="tag">加油</span>
                        <span class="tag is-grey">2</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E5%93%88%E5%A4%AB%E6%9B%BC%E6%A0%91/">
                        <span class="tag">哈夫曼树</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E5%A0%86%E6%A0%88/">
                        <span class="tag">堆栈</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E5%AD%A6%E4%B9%A0Vue-js/">
                        <span class="tag">学习Vue.js</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E5%BC%80%E5%8F%91%E8%BF%9B%E5%BA%A6/">
                        <span class="tag">开发进度</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E6%88%91%E5%A4%AA%E9%9A%BE%E4%BA%86/">
                        <span class="tag">我太难了</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E6%8B%AF%E6%95%91007/">
                        <span class="tag">拯救007</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/">
                        <span class="tag">数据结构</span>
                        <span class="tag is-grey">4</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E6%96%B0%E5%86%A0%E7%97%85%E6%AF%92/">
                        <span class="tag">新冠病毒</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E6%97%85%E6%B8%B8%E8%A7%84%E5%88%92/">
                        <span class="tag">旅游规划</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E6%97%A5%E5%BF%97/">
                        <span class="tag">日志</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E6%99%9A%E5%AE%89/">
                        <span class="tag">晚安</span>
                        <span class="tag is-grey">4</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E6%99%9A%E5%AE%89%E7%B3%BB%E5%88%97/">
                        <span class="tag">晚安系列</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E6%A0%88/">
                        <span class="tag">栈</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E6%A0%91/">
                        <span class="tag">树</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E6%B5%8F%E8%A7%88%E5%99%A8/">
                        <span class="tag">浏览器</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E7%AC%A6%E5%8F%B7%E9%85%8D%E5%AF%B9/">
                        <span class="tag">符号配对</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E8%B8%A9%E5%9D%91/">
                        <span class="tag">踩坑</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E8%BE%9B%E9%85%B8%E5%8E%86%E7%A8%8B/">
                        <span class="tag">辛酸历程</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E9%93%BE%E6%A0%88/">
                        <span class="tag">链栈</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E9%98%9F%E5%88%97/">
                        <span class="tag">队列</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E9%98%9F%E6%A0%88/">
                        <span class="tag">队栈</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E9%BB%98%E5%93%80/">
                        <span class="tag">默哀</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
            </div>
        </div>
    </div>
</div>
        
        </div>
    
</div>

                




<div class="column is-4-tablet is-4-desktop is-3-widescreen is-hidden-touch is-hidden-desktop-only has-order-3 column-right ">
    
        <div class="card widget">
    <div class="card-content">
        <h3 class="menu-label">
            Recent
        </h3>
        
        <article class="media">
            
            <div class="media-content">
                <div class="content">
                    <div><time class="has-text-grey is-size-7 is-uppercase" datetime="2020-05-12T15:09:00.000Z">2020-05-12</time></div>
                    <a href="/posts/10153.html" class="title has-link-black-ter is-size-6 has-text-weight-normal">晚安系列:聊聊最近的事情吧</a>
                    <p class="is-size-7 is-uppercase">
                        <a class="has-link-grey -link" href="/categories/%E6%99%9A%E5%AE%89%E7%B3%BB%E5%88%97/">晚安系列</a>
                    </p>
                </div>
            </div>
        </article>
        
        <article class="media">
            
            <div class="media-content">
                <div class="content">
                    <div><time class="has-text-grey is-size-7 is-uppercase" datetime="2020-04-26T09:58:00.000Z">2020-04-26</time></div>
                    <a href="/posts/31880.html" class="title has-link-black-ter is-size-6 has-text-weight-normal">关于队列、堆栈、树的数据结构总结</a>
                    <p class="is-size-7 is-uppercase">
                        <a class="has-link-grey -link" href="/categories/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E4%B8%8E%E7%AE%97%E6%B3%95/">数据结构与算法</a>
                    </p>
                </div>
            </div>
        </article>
        
        <article class="media">
            
            <div class="media-content">
                <div class="content">
                    <div><time class="has-text-grey is-size-7 is-uppercase" datetime="2020-04-05T01:47:00.000Z">2020-04-05</time></div>
                    <a href="/posts/19129.html" class="title has-link-black-ter is-size-6 has-text-weight-normal">开发进度：year9.cn完成了后端部分功能</a>
                    <p class="is-size-7 is-uppercase">
                        <a class="has-link-grey -link" href="/categories/%E6%88%91%E7%9A%84%E5%BC%80%E5%8F%91%E4%B9%8B%E8%B7%AF/">我的开发之路</a>
                    </p>
                </div>
            </div>
        </article>
        
        <article class="media">
            
            <div class="media-content">
                <div class="content">
                    <div><time class="has-text-grey is-size-7 is-uppercase" datetime="2020-04-03T12:11:00.000Z">2020-04-03</time></div>
                    <a href="/posts/17009.html" class="title has-link-black-ter is-size-6 has-text-weight-normal">全国哀悼日4月4日,为抗击疫情的战士们降半旗!</a>
                    <p class="is-size-7 is-uppercase">
                        <a class="has-link-grey -link" href="/categories/%E9%80%9A%E7%9F%A5/">通知</a>
                    </p>
                </div>
            </div>
        </article>
        
        <article class="media">
            
            <div class="media-content">
                <div class="content">
                    <div><time class="has-text-grey is-size-7 is-uppercase" datetime="2020-04-01T09:34:00.000Z">2020-04-01</time></div>
                    <a href="/posts/5527.html" class="title has-link-black-ter is-size-6 has-text-weight-normal">06-图2 Saving James Bond - Easy Version (25分)</a>
                    <p class="is-size-7 is-uppercase">
                        <a class="has-link-grey -link" href="/categories/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E4%B8%8E%E7%AE%97%E6%B3%95/">数据结构与算法</a>
                    </p>
                </div>
            </div>
        </article>
        
    </div>
</div>
    
        <div class="card widget">
    <div class="card-content">
        <div class="menu">
        <h3 class="menu-label">
            Archives
        </h3>
        <ul class="menu-list">
        
        <li>
            <a class="level is-marginless" href="/archives/2020/05/">
                <span class="level-start">
                    <span class="level-item">May 2020</span>
                </span>
                <span class="level-end">
                    <span class="level-item tag">1</span>
                </span>
            </a>
        </li>
        
        <li>
            <a class="level is-marginless" href="/archives/2020/04/">
                <span class="level-start">
                    <span class="level-item">April 2020</span>
                </span>
                <span class="level-end">
                    <span class="level-item tag">8</span>
                </span>
            </a>
        </li>
        
        <li>
            <a class="level is-marginless" href="/archives/2020/03/">
                <span class="level-start">
                    <span class="level-item">March 2020</span>
                </span>
                <span class="level-end">
                    <span class="level-item tag">22</span>
                </span>
            </a>
        </li>
        
        <li>
            <a class="level is-marginless" href="/archives/2020/02/">
                <span class="level-start">
                    <span class="level-item">February 2020</span>
                </span>
                <span class="level-end">
                    <span class="level-item tag">5</span>
                </span>
            </a>
        </li>
        
        </ul>
        </div>
    </div>
</div>
    
        <div class="card widget">
    <div class="card-content">
        <div class="menu">
            <h3 class="menu-label">
                Tags
            </h3>
            <div class="field is-grouped is-grouped-multiline">
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/Flash/">
                        <span class="tag">Flash</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/Linux/">
                        <span class="tag">Linux</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/Vue-js/">
                        <span class="tag">Vue.js</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E4%B8%AD%E5%9B%BD%E5%A4%A7%E5%AD%A6Mooc/">
                        <span class="tag">中国大学Mooc</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E5%8A%A0%E6%B2%B9/">
                        <span class="tag">加油</span>
                        <span class="tag is-grey">2</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E5%93%88%E5%A4%AB%E6%9B%BC%E6%A0%91/">
                        <span class="tag">哈夫曼树</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E5%A0%86%E6%A0%88/">
                        <span class="tag">堆栈</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E5%AD%A6%E4%B9%A0Vue-js/">
                        <span class="tag">学习Vue.js</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E5%BC%80%E5%8F%91%E8%BF%9B%E5%BA%A6/">
                        <span class="tag">开发进度</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E6%88%91%E5%A4%AA%E9%9A%BE%E4%BA%86/">
                        <span class="tag">我太难了</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E6%8B%AF%E6%95%91007/">
                        <span class="tag">拯救007</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/">
                        <span class="tag">数据结构</span>
                        <span class="tag is-grey">4</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E6%96%B0%E5%86%A0%E7%97%85%E6%AF%92/">
                        <span class="tag">新冠病毒</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E6%97%85%E6%B8%B8%E8%A7%84%E5%88%92/">
                        <span class="tag">旅游规划</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E6%97%A5%E5%BF%97/">
                        <span class="tag">日志</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E6%99%9A%E5%AE%89/">
                        <span class="tag">晚安</span>
                        <span class="tag is-grey">4</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E6%99%9A%E5%AE%89%E7%B3%BB%E5%88%97/">
                        <span class="tag">晚安系列</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E6%A0%88/">
                        <span class="tag">栈</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E6%A0%91/">
                        <span class="tag">树</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E6%B5%8F%E8%A7%88%E5%99%A8/">
                        <span class="tag">浏览器</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E7%AC%A6%E5%8F%B7%E9%85%8D%E5%AF%B9/">
                        <span class="tag">符号配对</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E8%B8%A9%E5%9D%91/">
                        <span class="tag">踩坑</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E8%BE%9B%E9%85%B8%E5%8E%86%E7%A8%8B/">
                        <span class="tag">辛酸历程</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E9%93%BE%E6%A0%88/">
                        <span class="tag">链栈</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E9%98%9F%E5%88%97/">
                        <span class="tag">队列</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E9%98%9F%E6%A0%88/">
                        <span class="tag">队栈</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
                <div class="control">
                    <a class="tags has-addons" href="/tags/%E9%BB%98%E5%93%80/">
                        <span class="tag">默哀</span>
                        <span class="tag is-grey">1</span>
                    </a>
                </div>
                
            </div>
        </div>
    </div>
</div>
    
    
</div>

            </div>
        </div>
    </section>
    <footer class="footer">
    <div class="container">
        <div class="level">
            <div class="level-start has-text-centered-mobile">
                <a class="footer-logo is-block has-mb-6" href="/">
                
                    <img src="/images/logo.png" alt="「转」Mysql增删改查" height="28">
                
                </a>
                <p class="is-size-7">
                &copy; 2020 YEAR9&nbsp;
                Powered by <a href="#" target="_blank" rel="noopener">Hexo</a> & <a
                        href="#" target="_blank" rel="noopener">Icarus</a> Realy thank them.
                        <br>
                         <img src="https://www.year9.cn/static/index/img/beian.png">公安备案:35012402000016 ICP备案:闽ICP备17020129号-3
                
                </p>
            </div>
            <div class="level-end">
            
                <div class="field has-addons is-flex-center-mobile has-mt-5-mobile is-flex-wrap is-flex-middle">
                
                <p class="control">
                    <a class="button is-white is-large" target="_blank" rel="noopener" title="Creative Commons" href="https://creativecommons.org/">
                        
                        <i class="fab fa-creative-commons"></i>
                        
                    </a>
                </p>
                
                <p class="control">
                    <a class="button is-white is-large" target="_blank" rel="noopener" title="Attribution 4.0 International" href="https://creativecommons.org/licenses/by/4.0/">
                        
                        <i class="fab fa-creative-commons-by"></i>
                        
                    </a>
                </p>
                
                <p class="control">
                    <a class="button is-white is-large" target="_blank" rel="noopener" title="Download on GitHub" href="https://gitee.com/year9">
                        
                        <i class="fab fa-github"></i>
                        
                    </a>
                </p>
                
                </div>
            
            </div>
        </div>
    </div>
</footer>
    <script src="https://cdn.jsdelivr.net/npm/jquery@3.3.1/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/moment@2.22.2/min/moment-with-locales.min.js"></script>
<script>moment.locale("en");</script>


<script>
var IcarusThemeSettings = {
    site: {
        url: 'https://blog.year9.cn',
        external_link: {"enable":true,"exclude":[]}
    },
    article: {
        highlight: {
            clipboard: true,
            fold: 'unfolded'
        }
    }
};
</script>


<script src="https://cdn.jsdelivr.net/npm/clipboard@2.0.4/dist/clipboard.min.js" defer></script>





<script src="/js/animation.js"></script>



<script src="https://cdn.jsdelivr.net/npm/lightgallery@1.6.8/dist/js/lightgallery.min.js" defer></script>
<script src="https://cdn.jsdelivr.net/npm/justifiedGallery@3.7.0/dist/js/jquery.justifiedGallery.min.js" defer></script>
<script src="/js/gallery.js" defer></script>



<div id="outdated">
    <h6>Your browser is out-of-date!</h6>
    <p>Update your browser to view this website correctly. <a id="btnUpdateBrowser" href="http://outdatedbrowser.com/">Update
            my browser now </a></p>
    <p class="last"><a href="#" id="btnCloseUpdateBrowser" title="Close">&times;</a></p>
</div>
<script src="https://cdn.jsdelivr.net/npm/outdatedbrowser@1.1.5/outdatedbrowser/outdatedbrowser.min.js" defer></script>
<script>
    document.addEventListener("DOMContentLoaded", function () {
        outdatedBrowser({
            bgColor: '#f25648',
            color: '#ffffff',
            lowerThan: 'flex'
        });
    });
</script>


<script src="https://cdn.jsdelivr.net/npm/mathjax@2.7.5/unpacked/MathJax.js?config=TeX-MML-AM_CHTML" defer></script>
<script>
document.addEventListener('DOMContentLoaded', function () {
    MathJax.Hub.Config({
        'HTML-CSS': {
            matchFontHeight: false
        },
        SVG: {
            matchFontHeight: false
        },
        CommonHTML: {
            matchFontHeight: false
        },
        tex2jax: {
            inlineMath: [
                ['$','$'],
                ['\\(','\\)']
            ]
        }
    });
});
</script>


<a id="back-to-top" title="Back to Top" href="javascript:;">
    <i class="fas fa-chevron-up"></i>
</a>
<script src="/js/back-to-top.js" defer></script>














<script src="/js/main.js" defer></script>

    
    <div class="searchbox ins-search">
    <div class="searchbox-container ins-search-container">
        <div class="searchbox-input-wrapper">
            <input type="text" class="searchbox-input ins-search-input" placeholder="Type something..." />
            <span class="searchbox-close ins-close ins-selectable"><i class="fa fa-times-circle"></i></span>
        </div>
        <div class="searchbox-result-wrapper ins-section-wrapper">
            <div class="ins-section-container"></div>
        </div>
    </div>
</div>
<script>
    (function (window) {
        var INSIGHT_CONFIG = {
            TRANSLATION: {
                POSTS: 'Posts',
                PAGES: 'Pages',
                CATEGORIES: 'Categories',
                TAGS: 'Tags',
                UNTITLED: '(Untitled)',
            },
            CONTENT_URL: '/content.json',
        };
        window.INSIGHT_CONFIG = INSIGHT_CONFIG;
    })(window);
</script>
<script src="/js/insight.js" defer></script>
<link rel="stylesheet" href="/css/search.css">
<link rel="stylesheet" href="/css/insight.css">
    
</body>
<script src="/live2d-widget/autoload.js"></script>
<script>
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>
</html>